using FSM.IBll; 
using FSM.Model; 
using FSM.Web.Models; 
using FSM.Web.Models.Fileter; 
using Microsoft.AspNetCore.Mvc; 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Threading.Tasks; 
 
namespace FSM.Web.Controllers 
{ 
    public class LogLoginController : BaseController 
    { 
        #region 模块 
 
        private readonly DataResultModel drm; 
 
        private readonly ILogLoginBll _bll; 
 
        #endregion 
 
        #region 构造函数 
 
        public LogLoginController(ILogLoginBll bll) 
        { 
            _bll = bll; 
            drm = new DataResultModel(); 
            ModuleNo = "0109"; 
        } 
 
        #endregion 
 
        #region 功能 
 
        public IActionResult Index() 
        { 
            return View(); 
        } 
 
        [HttpPost] 
        [ResultExceptionFilter] 
        [OperateAuthorize("0109", "Query")] 
        public JsonResult Get(int id) 
        { 
            log_login model = _bll.Get(id); 
            drm.success = true; 
            drm.data = model; 
            return drm.ToJson();
        }

        /// <summary> 
        /// 查询 
        /// </summary> 
        /// <param name="start_date">查询启始日期</param> 
        /// <param name="end_date">查询结束日期</param> 
        /// <param name="log_user">登录人員</param> 
        /// <param name="log_type">登录类型
        /// 1：網頁  
        /// 2：移動APP
        /// 3：Api</param> 
        /// <param name="log_terminal">登录设备
        /// 1：电脑
        /// 2：手机
        /// 3：Pad</param> 
        /// <param name="log_ip">登录IP</param> 
        [HttpPost] 
        [ResultExceptionFilter] 
        [OperateAuthorize("0109", "Query")] 
        public JsonResult List(DateTime? start_date, DateTime? end_date, string log_user, int? log_type, int? log_terminal, string log_ip, int? page = 1, int? page_size = 30) 
        {
            Tuple<List<log_login>, int> result = _bll.ListPagin(start_date, end_date, log_user, log_type, log_terminal, log_ip, page.Value, page_size.Value);
            drm.success = true; 
            drm.data = result.Item1; 
            drm.total = result.Item2; 
            return new JsonResult(drm); 
        } 
 
        #endregion 
    } 
} 
